package com.rc.saas.mini.service.enterprise;

import com.rc.saas.mini.mapper.enterprise.EnterpriseMemberApplyMapper;
import com.rc.saas.mini.model.enterprise.EnterpriseMemberApply;
import com.rc.saas.mini.model.enterprise.EnterpriseMemberApplyExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wangzhengwei
 * @create 2021/4/25
 */
@Service
public class EnterpriseMemberApplyServiceImpl implements EnterpriseMemberApplyService {
    @Autowired
    private EnterpriseMemberApplyMapper enterpriseMemberApplyMapper;

    @Override
    public EnterpriseMemberApplyMapper getMapper() {
        return enterpriseMemberApplyMapper;
    }

    @Override
    public EnterpriseMemberApply selectByMemberId(Long memberId, String tenantCode) {
        EnterpriseMemberApplyExample enterpriseMemberApplyExample = new EnterpriseMemberApplyExample();
        enterpriseMemberApplyExample.createCriteria().andTenantCodeEqualTo(tenantCode).andMemberIdEqualTo(memberId);
        enterpriseMemberApplyExample.setOrderByClause("created_time  desc");
        return enterpriseMemberApplyMapper.selectByExample(enterpriseMemberApplyExample).stream().findFirst().orElseGet(() -> null);
    }

    @Override
    public int insertByReturnId(EnterpriseMemberApply enterpriseMemberApply) {
        return enterpriseMemberApplyMapper.insertByReturnId(enterpriseMemberApply);
    }

    @Override
    public List<EnterpriseMemberApply> listByCondition(EnterpriseMemberApply enterpriseMemberApply) {
        return enterpriseMemberApplyMapper.listByCondition(enterpriseMemberApply);
    }
}
